<!DOCTYPE html >
<html lang="zh-CN">

    <head>
        <meta charset="utf-8">
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
        <title>page</title>
        <link rel="stylesheet" href="../common/mui/mui.css" />
        <link rel="stylesheet" href="../common/common.css" />
    </head>

    <body>

        <div class="mui-content pt0">
            <ul class="mui-table-view ">
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="open">open(打开新页面)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="open2">open(style为-1)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="openLocal">openLocal(打开特定原生页面)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="close">close(关闭页面)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="close3">close(关闭3层页面)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="reload">reload(重载页面)</a>
                </li>
            </ul>
        </div>
        <script type="text/javascript" src="../common/mui/mui.js"></script>
        <script type="text/javascript" src="../../dist/quick.js"></script>
        <script type="text/javascript" src="../../dist/quick.native.js"></script>
        <script type="text/javascript" src="../../dist/quick.h5.js"></script>
        <script type="text/javascript" src="../common/common.js"></script>
        <script>
            window.runApi = function(id) {
                console.log('执行API:' + id);

                switch (id) {
                    case 'open':
                        quick.page.open({
                            pageUrl: "../simple.html",
                            pageTitle: '测试页面标题',
                            // 横竖屏,默认为1表示竖屏
                            orientation: '1',
                            // 额外数据
                            data: {
                                key1: 'value1'
                            },
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'open2':
                        quick.page.open({
                            pageUrl: "../simple.html",
                            pageTitle: '测试页面标题',
                            // 横竖屏,默认为1表示竖屏
                            orientation: '1',
                            pageStyle: -1,
                            // 额外数据
                            data: {
                                key1: 'value1'
                            },
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'openLocal':
                        var className = quick.os.android ? 'com.quick.core.baseapp.baseactivity.FrmFragmentActivity' : 'EPTFileSelectViewController';

                        quick.page.openLocal({
                            className: className,
                            // 为1则是打开已存在的页面，会杀掉所有该页面上的页面
                            isOpenExist: '0',
                            // 额外数据，注意额外数据只能一层键值对形式，不能再包裹子json
                            data: {
                                key: 'value1'
                            },
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'close':
                        // 可以传json也可以传字符串，底层都会默认转成字符串的
                        quick.page.close({
                            resultData: {
                                key: 'value2'
                            },
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        // 兼容如下调用，兼容模式只允许传递字符串
                        // quick.page.close('value2');
                        break;
                    case 'close3':
                        // 可以一次性关闭多个页面，页面传值不再有意义
                        quick.page.close({
                            popPageNumber: 3,
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'reload':
                        quick.page.reload();
                        break;
                    default:
                        console.error('错误！没有相应API');
                }
            };
        </script>

    </body>

</html>